<!DOCTYPE html>
<html>
<head>
    <title>文档管理</title>
    <include file='public/head'>
    <link rel="stylesheet" href="__STATIC__/js/jquery-ui/jquery-ui.css">	
	<style>
		.layui-legend-size{font-size:28px !important;}
		.layui-nopadding{padding:0 !important;}
		.layui-overflow{overflow:auto;}
		.layui-nomargin{margin: 0 !important;}
		.layui-bottom{border-bottom:1px solid rgb(226, 226, 226);}
		.layui-input{height:30px !important; }
		.layui-form-search-item .layui-inline{margin-bottom: 5px;} 
		.layui-form-search-item label{margin-left: 15px;}
		.layui-table-page {padding: 7px 0px 0px;}
		.layui-field-padding{border-width: 1px;padding:0 0 5px 10px;}
	</style>
</head>
<body>

	<div class="layui-tab " lay-filter="demo-tab">
		<div class="layui-card">
			<div class="layui-card-header layui-bg-gray layui-bottom">
				<form class="layui-form" action="">
				      <div class="layui-input-inline" style="width:50%">
				        <select name="modules" lay-filter="list" lay-verify="required" lay-search="">
				          <option value="0">直接选择或搜索选择</option>
				          {$select}
				        </select>
				      </div>
				     
				      <!-- <button type="submit" class="layui-btn layui-btn-sm layui-btn-primary " style="font-weight:800;" lay-submit="" lay-filter="demo2"><i class="layui-icon "></i>搜索</button> -->
				</form>
			</div>
		</div>
	</div>	

	<!-- 选择内容显示 -->
	<div class="layui-container"  id="cont" hidden="true">
		<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
		  <legend id="title" style="font-size: 30px;">此处标题</legend>
		</fieldset>		
		<blockquote class="layui-elem-quote layui-quote-nm" id="owner">此处文章信息</blockquote>
		<div class="layui-row">
			<div class="layui-col-md2"></div>
			<div class="layui-col-md12" class="layui-input-inline">
				<fieldset class="layui-elem-field" class="layui-input-inline">
				  <legend id="btn">
				  	<div id="pa" class="layui-input-inline"></div>
				  	<div id="ed" class="layui-input-inline"></div>
				  	<div id="de" class="layui-input-inline"></div>
				  </legend>
				  <div class="layui-field-box" style="word-break:break-all; width:1150px;">
				  	<ul id="content" style="font-size: 16px;">

				  	</ul>
				  </div>
				</fieldset>	
			</div>
			<div class="layui-col-md2"></div>
		</div>
	</div>
	<!-- 选择内容显示 -->
<include file='public/scripts'>
<script src="__STATIC__/js/jquery-ui/jquery-ui.js"></script>

<script type="text/javascript">

	  var form = layui.form;
//排序
	  function sort(){
	    $( "#content" ).sortable({
	        opactiy:0.6,
	        revert:true,
	        cursor:"move",
	        update:function(){
	            
	        }
	    });
	   }
	 
	    //选择触发
		form.on('select(list)', function(data){
            // let selectText=data.elem[data.elem.selectedIndex].text;//得到被选中的文本值
            //去空格
            // selectText=selectText.replace(/\s+/g, "");
            // data.elem[data.elem.selectedIndex].text=selectText;//覆盖原文本值
            //选中的id进行跳转
			tz(data.elem[data.elem.selectedIndex].value);    
        });

		//触发文档内容获取
		function choose(id){
			var content = {};
			content['id'] = id;
			if(content['id']){
            	//选中的默认值
				$.ajax({
					url:"{:cmf_plugin_url('Word://public/wordContent')}",
					data:content,
					//得到选中的内容
					success:function(data){
						if(data.type=='success'){
							// console.log(data.info);

							if(id != '0'){
								//标题显示
								$('#title').html(data.info.name);
								//文件拥有人显示
								$('#owner').html('本文件由<b>'+data.info.uname+'</b>创建');
							}else{
								$('#title').html('<h2>首页</h2>');
								$('#owner').hide();
							}
							
							//内容显示
							$('#content').html(data.info.content);
							//判断有无编辑权限
							if(data.info.edit == 1){
								
							}else{
								$('#ed').html("");
							}
							//判断有无删除权限
							if(data.info.del == 1){
								
							}else{
								$('#de').html("");
							}

							if(data.info.edit == 1 || data.info.parent_id){
								$('#pa').html("<a class='layui-btn layui-btn-xs word-edit' onclick='tz("+data.info.parent_id+")'><i class='layui-icon layui-icon-return'></i>返回</a>");
								$('#btn').show();
							}else{
								$('#btn').hide();
							}

							//显示整个组件
							$('#cont').removeAttr('hidden');
						}else if(data.type=='error'){
							layer.msg(data.msg);
						}
						// console.log(data);
					},
					error:function(data){
						layer.msg('查询失败');
						return false;
					}
				})	
			} 			 			
		}

		
		





		function tz(id){
			window.location.href = "{:cmf_plugin_url('Word://public/index')}?id="+id;
		}

		<php>
				echo "choose('".$id."')";
		</php>

</script>
</body>
</html>